<%@page import="java.util.List,com.crm.entity.Opportunity" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/temp.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<!-- InstanceEndEditable -->
<link href="<%=application.getContextPath() %>/css/css-crm.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=application.getContextPath()%>/js/jquery-1.6.min.js"></script>	
<script type="text/javascript" src="<%=application.getContextPath()%>/js/jquery-ui-1.8.17.custom.min.js"></script>	
<link rel="stylesheet" href="<%=application.getContextPath()%>/css/jquery-ui-1.8.17.custom.css"/>

<script language="JavaScript" src="<%=application.getContextPath()%>/js/gen_validatorv4.js" type="text/javascript" ></script>
<script type="text/javascript" src="<%=application.getContextPath()%>/js/jquery.validate.js"></script>	
<script type="text/javascript" src="<%=application.getContextPath()%>/js/jquery.validate.min.js"></script>


</head>

<body>
<div id="main">
  
  <%@include file="common/header.jsp" %>
  <%@include file="common/submenu.jsp" %>
  <div id="content"><!-- InstanceBeginEditable name="EditRegion3" -->
   <form  name="inform" action="<%=application.getContextPath() %>/invoice/genInvoice.do" method="post" >
    <div id="work-area2">
      <div class="heading2">Invoice </div>
	<div id="enqclient" style="display: none;" align="center" class="result_msg"></div>
      <div class="boxIFS">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
              
              <tr>
                <td width="16">&nbsp;</td>
                <td width="119">&nbsp;</td>
                <td width="150">&nbsp;</td>
                <td width="137">&nbsp;</td>
                <td width="178">&nbsp;</td>
                <td width="122">&nbsp;</td>
              </tr>
              <tr>
                <td height="28">&nbsp;</td>
                <td align="left" valign="top">Reference Number </td>
                <td align="left" valign="top">
                <select name="refNo" class="form" id="refNoId">
                <option value="">Please Select</option>
                <%
                if(request.getAttribute("opportunityList")!=null){
                	List<Opportunity> lopp=(List<Opportunity>)request.getAttribute("opportunityList");
                	for(int i=0;i<lopp.size();i++){                	
                	%>
                	<option value="<%=lopp.get(i).getRefNum()%>"><%=lopp.get(i).getRefNum()%></option>
              <%   }
                	}
                %>
                </select></td>
                <td width="137">Quotation Number </td>
                <td align="left" valign="top"><select name="quotNo" class="form" id="quotNoId">
                  <option value="">Please Select</option>
                </select></td>
                <td align="left" valign="top"><input type="button" class="button"  id="getin" value="Get Invoice"/></td>
              </tr>
              
              
              <tr>
                <td height="5"></td>
                <td height="5" align="left" valign="top"></td>
                <td height="5" align="left" valign="top"></td>
                <td align="left" valign="top"></td>
                <td align="left" valign="top"></td>
                <td align="left" valign="top"></td>
              </tr>
              
              <tr>
                <td height="5"></td>
                <td height="5" align="left" valign="top"></td>
                <td height="5" align="left" valign="top"></td>
                <td align="left" valign="top"></td>
                <td align="left" valign="top"></td>
                <td align="left" valign="top"></td>
                <td width="4" align="left" valign="top"></td>
              </tr>
              
              <tr>
                <td width="16">&nbsp;</td>
                <td align="left" valign="top">&nbsp;</td>
                <td align="left" valign="top">&nbsp;</td>
                <td align="left" valign="top">&nbsp;</td>
                <td align="left" valign="top">&nbsp;</td>
                <td align="left" valign="top">&nbsp;</td>
                <td align="left" valign="top">&nbsp;</td>
              </tr>
              <tr>
                <td height="5"></td>
                <td height="5" align="left" valign="top"></td>
                <td height="5" align="left" valign="top"></td>
                <td align="left" valign="top"></td>
                <td align="left" valign="top"></td>
                <td align="left" valign="top"></td>
                <td align="left" valign="top"></td>
              </tr>
        </table>
      </div>
      
       <div id="ajaxLoader" style="display:none" align="center"><img src="<%=application.getContextPath()%>/images/ajax_loader.gif"/></div>
	  
	   <table style="height:350px; width:910px;" ><tr><td> <div class="boxtable" id="tabId"></div></td></tr></table> 
	
	 

	  
    </div>
  </form>
  </div><div id="footer"></div>  
</div>
</body>
<!-- InstanceEnd --></html>
<script type="text/javascript">
$("#getin").click(function(){
	var refNo=$("#refNoId").val();
	var quotNo=$("#quotNoId").val();
	 if(refNo==null || refNo==""|| (quotNo="" )){
		 jAlert("Please Select Reference Number and Quotation");
		 return false;
	 }
	 else{
	var quotNo=$("#quotNoId").val();
	data="refNo="+refNo+"&quotNo="+quotNo;
	$("#ajaxLoader").show();
	$.ajax({
		url:"<%=application.getContextPath()%>/invoice/setInvoice.do",
		data:data,
		success:function(res){
			$("#tabId").html(res);
		}
}).done(function(html){
	$("#ajaxLoader").hide();
}).fail(function(html){
	$("#ajaxLoader").hide();
	alert("Failed To Load the Data");
});
	 }
});

$("#refNoId").change(function(){
	var refNo=$("#refNoId").val();
	 if(refNo==null || refNo==""){
		 jAlert("Please Select Reference Number and Quotation");
		 return false;
	 }
	 else
		 {
	data="refNo="+refNo;
	$("#ajaxLoader").show();
	$.ajax({
		url:"<%=application.getContextPath()%>/invoice/quotSearch.do",
		data:data,
		success:function(res){
			var e2=document.getElementById('quotNoId');
			$('#quotNoId')
		    .find('option')
		    .remove()
		    .end()
		   	;
			var temp=res.split(",");
			if(temp != null || temp!=" "){
				var o=document.createElement('option');
				o.value="";
				o.text="Please Select";
				e2.options.add(o);
				for(var i=0;i<temp.length-1;i++){
					var o=document.createElement('option');
					o.value=temp[i];
					o.text=temp[i];
					e2.options.add(o);
				}
			}
		}
	}).done(function(html){
		$("#ajaxLoader").hide();
	  }).fail(function(html){
	  	$("#ajaxLoader").hide();
	  	alert("Failed To Load the Data");
	  });
		 }
});
</script>
